<!DOCTYPE html>
<html>

<head>
    <title>游记列表</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/travel.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/plugins/jquery-form/jquery.form.js"></script>

    <script>
        $(function () {
            //分页临时变量
            var currentPage = 1;
            //Jrender到下一页时,会自动把上一页的数据丢弃
            var dataList = [];	//分页缓存数据
            //解决一直翻页的问题
            var totalPage = 1;	//总页数

            function query() {
                //第一页数据
                $.get("/travels",{currentPage:currentPage},function (data) {

                    //保存当前页数据
                    //me让age合并2个数组,返回合并后数组,将上一页和当前页的数据合并成一个数组
                    dataList = $.merge(dataList,data.list);//数组形式[xxx,xxx,xxx,xxx]

                    //{list:dataList},表示将dataList数组放到一个list对象中
                    $("#allTravels").renderValues({list:dataList},{
                        setHref:function (item,value) {
                            $(item).attr("href",$(item).data("href") + value);
                        },
                        setUserHref:function (item, value) {
                            $(item).attr("href",$(item).data("userhref") + value);
                        }
                    });
                    currentPage+=1;//下一页,当屏幕滚动式才会自动+1

                    totalPage = data.pages;//总页数
                });


            };
            query();

            //屏幕滚动事件
            $(window).scroll(function () {
                //手机屏幕高度+滚动高度>=页面高度时才进行翻页
                if($(window).height() + $(document).scrollTop() + 1 >= $(document).height()){
                    if(currentPage <= totalPage){
                        //给下一页回显数据
                        query();
                    }else{
                        $(document).dialog({
                            type : 'notice',
                            infoText: "够了,到底了,难受...",
                            autoClose: 1000,
                            position: 'bottom'  // center: 居中; bottom: 底部
                        });
                    }

                }
            });
            $.get("travels/commends",{type:1,pageSize:3},function (data) {
                $("#travelsCommends").renderValues(data,{
                    setHref:function (item, value) {
                        $(item).attr("href",$(item).data("href") + value);
                    }
                });
                $(".carousel-item:first").addClass("active");
            });
            showComments();
        });
        function showComments(){
            var Mar = document.getElementsByClassName("Marquee")[0];
            var child_div=Mar.getElementsByTagName("div");
            var picH = 50;//移动高度
            var scrollstep=3;//移动步幅,越大越快
            var scrolltime=20;//移动频度(毫秒)越大越慢
            var stoptime=2000;//间断时间(毫秒)
            var tmpH = 0;
            Mar.innerHTML += Mar.innerHTML;
            function start(){
                if(tmpH < picH){
                    tmpH += scrollstep;
                    if(tmpH > picH )tmpH = picH ;
                    Mar.scrollTop = tmpH;
                    setTimeout(start,scrolltime);
                }else{
                    tmpH = 0;
                    Mar.appendChild(child_div[0]);
                    Mar.scrollTop = 0;
                    setTimeout(start,stoptime);
                }
            }
            setTimeout(start,stoptime)
        }
    </script>
</head>

<body>


<div class="search-head">
    <div class="row nav-search">
        <div class="col-2">
            <a href="index.html">
                <span><i class="fa fa-chevron-left fa-2x"></i></span>
            </a>
        </div>
        <div class="col-10">
            <div class="input-group-sm search">
                <input class="form-control searchBtn" placeholder="搜游记">
            </div>
        </div>
    </div>
</div>


<div class="container">

    <h6>每月冠军游记</h6>
    <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
        <div class="Marquee"  >
        <div id="travelsCommends" class="carousel-inner">
            <div class="carousel-inner" render-loop="list">
                <div class="carousel-item">
                    <a data-href="/travelContent.html?id=" render-fun="setHref" render-key="list.travel_id">
                        <img class="d-block w-100"  render-src="list.coverUrl" width="100%" height="200px">
                        <span class="recommend" render-html="list.title"></span></a>
                        <span class="recommend" render-html="list.subTitle"></span></a>
                    <div class="recommend-author">
                    <a href="#">
                        <img  class="rounded-circle" style="width: 10%;" render-src="list.coverUrl">
                        <span render-html="list.u_nickName"></span>
                    </a>在&nbsp;
                        <span render-html="list.p_name"></span>
                    </div>
                </div>
            </div>
        </div>
        </div>
        <a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
            <span class="carousel-control-prev-icon" aria-hidden="true"></span>
            <span class="sr-only"></span>
        </a>
        <a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"></span>
            <span class="sr-only"></span>
        </a>
    </div>
</div>

<div class="container">
    <h6>全部游记</h6>
    <div id="allTravels">

        <div render-loop="list">
        <div class="row detail" >
            <div class="col">
                <a data-href="/travelContent.html?id=" render-fun="setHref" render-key="list.id">
                    <h4 render-html="list.title"></h4>
                </a>
                <p>
                    <a data-userhref="/userProfile.html?id=" render-fun="setUserHref" render-key="list.author.id">
                        <img class="rounded-circle head-img" render-src="list.author.headImgUrl">
                        <span render-html="list.author.nickName"></span> </a> 在
                    <span class="addr" render-html="list.place.name">成都</span>
                </p>
                <p>
                    <i class="fa fa-eye fa-fw"></i>
                    <span>0</span>
                    <i class="fa fa-commenting fa-fw"></i>
                    <span>0</span>
                </p>
            </div>
            <div class="col bigimg">
                <a data-href="/travelContent.html?id=" render-fun="setHref" render-key="list.id" >
                    <img render-src="list.coverUrl">
                </a>
            </div>
        </div>
        </div>

    </div>
</div>



</body>

</html>